<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<!-- 文件显示功能 -->
<?php
include_once 'mysql_connect.php';
	// $filename="1.txt";
	// header('content-disposition:attachment;filename='.$filename);
	// header('content-length:'.filesize($filename));
	// readfile($filename);
//上面是下载功能设置
$dir=dirname(__FILE__);//这里输入其它路径
//PHP遍历文件夹下所有文件
$handle=opendir($dir.".");
//定义用于存储文件名的数组
$array_file = array();
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..") {
$array_file[] = $file; //输出文件名
	}
}
closedir($handle);
foreach ($array_file as $value) {
	print_r($value."<br/>");
	$sql="INSERT INTO file VALUES('',$value)";
	$mysqli->query($sql);
}
?>
<!-- 下载功能 -->
<a class="download">a</a>
<script type="text/javascript">
	$(".download").attr("href","http://127.0.0.1/data/uploads/1.rar");
</script>	
</body>
</html>
